﻿public enum LockType
{
    UnLock = 1,
    LoadingWait = 2,
    GuideDelay = 4,
    SceneLoading = 8,
    CarResLoading = 16,
}

public class UIInputMgr : Singleton<UIInputMgr>
{
    /// <summary>
    /// 当前锁定类型
    /// </summary>
    private LockType type = LockType.UnLock;

    /// <summary>
    /// 解锁 允许输入
    /// </summary>
    /// <param name="nType"></param>
    public void UnLockInput(LockType nType)
    {
        type ^= nType;
        if (type == LockType.UnLock)
        {
            SetUIInput(true);
        }
    }

    /// <summary>
    /// 锁定 禁止输入
    /// </summary>
    /// <param name="nType"></param>
    public void LockInput(LockType nType)
    {
        type |= nType;
        if (type != LockType.UnLock)
        {
            SetUIInput(false);
        }
    }

    /// <summary>
    /// 设置操作锁定
    /// </summary>
    /// <param name="open"></param>
    private void SetUIInput(bool open)
    {
        for (int i = 0; i < UICamera.list.size; i++)
        {
            UICamera.list[i].useMouse = open;
            UICamera.list[i].useTouch = open;
        }
    }

    /// <summary>
    /// 断线重连的时候，解除输入锁定
    /// </summary>
    public void ClearLockUIInput()
    {
        type = LockType.UnLock;
        SetUIInput(true);
    }
}